<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/admin/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>试卷分类列表</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="../css/backCss.css">


<link rel="stylesheet" type="text/css" href="../css/list.css">

<script type="text/javascript"> 
	var allChecked = false;
	//全选/反选操作 	
	function checkAll() {
		if (allChecked == false) {
			allChecked = true;
		} else {
			allChecked = false;
		}
		var checks = document.getElementsByName("checkIDs");
		for ( var i = 0; i < checks.length; i++) {
			checks[i].checked = allChecked;//ifAll.checked;
		}
	}
	//双击行的时候选中或撤销选中
	function checkRow(row) {
		var cell = row.cells[0]; //取得当前行的第一列
		var input = cell.getElementsByTagName("input")[0];//取得列中的第一个input 
		if (input.checked) {
			input.checked = "";
		} else {
			input.checked = "checked";
		}
	}
	//批量删除 
	function deleteList() {
		var checks = document.getElementsByName("checkIDs");
		var flag = false;

		for ( var i = 0; i < checks.length; i++) {
			if (checks[i].checked) {
				flag = true;
				break;
			}
		}

		if (!flag) {
			alert("请选择至少一条需要删除的用户记录！");
			return;
		}
		if (window.confirm("确认删除吗？")) {
			with (document.getElementById("pstform")) {
				action = "deleteListPaperSourceType.action";
				method = "post";
				submit();
			}
		}
	}

	//删除信息
	function deletePaperSourceType(uid) {
		if (window.confirm("确定要删除吗？")) {
			with (document.getElementById("pstform")) {
				action = "deletePaperSourceType.action?id=" + uid;
				method = "post";
				submit();
			}
		}
	}
	//首页
	function topPage() {
		if(document.getElementById("currentPage").value==1){ 
			return;
		}
		with (document.getElementById("pstform")) {
			document.getElementById("currentPage").value = 1  ; 
			action="listByWherePagePaperSourceType.action";
			method="post";
			submit();
		} 
	}
	//前一页
	function previousPage() {
		if(document.getElementById("currentPage").value==1){ 
			return;
		}
		with (document.getElementById("pstform")) {
			document.getElementById("currentPage").value = ${page.currentPage-1}  ; 
			action="listByWherePagePaperSourceType.action";
			method="post";
			submit();
		}  
	}	
	//后一页
	function nextPage() {
		var totalPage = ${page.totalPage};
		if(document.getElementById("currentPage").value==totalPage ){  
			return;
		}
		with (document.getElementById("pstform")) {
			document.getElementById("currentPage").value = ${page.currentPage+1}  ; 
			action="listByWherePagePaperSourceType.action";
			method="post";
			submit();
		}  
	}
	//最后一页
	function bottomPage() {
		var totalPage = ${page.totalPage};
		if(document.getElementById("currentPage").value== totalPage ){  
			return;
		}
		with (document.getElementById("pstform")) {
			document.getElementById("currentPage").value =  ${page.totalPage}  ; 
			action="listByWherePagePaperSourceType.action";
			method="post";
			submit();
		}   
	}
	//修改每页显示的数量
	 function changEveryPage(){ 
			with (document.getElementById("pstform")) {
			//	document.getElementById("currentPage").value =  1 ;   
				action="listByWherePagePaperSourceType.action";
				method="post";
				submit();
			}  
	 }

	function listByWhere(){
		with (document.getElementById("pstform")) {
			document.getElementById("currentPage").value =  1 ;  
			action="listByWherePagePaperSourceType.action";
			method="post";
			submit();
		}  
	} 
</script>
</head>

<body>

	<div class="top" align="center">
		<jsp:include page="top.jsp"></jsp:include>
	</div>
	<div class="content" align="center">
		<div align="center" class="main">
			<h3>试卷来源分类管理</h3>

			<div class="sort_c" align="center">
				<form action="listByWherePagePaperSourceType.action" id="pstform"
					name="pstform" method="post">
					<div align="center">
						类型名称： <input type="text" name="name" id="mame"/> <input type="submit"
							value="条件查询" />
					</div>
					<s:if
						test="#request.pstList == null || #request.pstList.size() == 0">
						<div align="center">
							<font color="red"><b>没有查询到内容分类的相关数据信息</b> </font> &nbsp;&nbsp;  
						</div>
					</s:if>
					<s:else>
						<div align="center" style="padding-top: 5">
							<table cellspacing="0" cellpadding="0" border="1"
								style="border-collapse: collapse;" bordercolor="black">
								<tr height="25" class="trth">
									<th width="60" onclick="checkAll()">全/反选</th>
									<th width="200">名称</th>
									<th width="200">备注</th>
									<th width="45">ID号</th>
									<th width="200">操作</th>
								</tr>
								<s:iterator id="pst" value="#request.pstList" status="stu">
									<tr align="center" height="25" class="trtd" id="trtd"
										ondblclick="checkRow(this)">
										<td><input type="checkbox" name="checkIDs" id="checkIDs"
											value="${pst.id }" />
										</td>
										<td>${pst.name }</td>
										<td>${pst.remark }</td>
										<td>${pst.id }</td>
										<td><a href="editPaperSourceType.action?id=${pst.id }"
											style="text-decoration: none; color: #0F3763;">编辑</a> <a
											href="javascript:deletePaperSourceType(${pst.id })"
											style="text-decoration: none; color: #0F3763;">删除</a>
										</td>
									</tr>
								</s:iterator>
							</table>
						</div>
					</s:else>
					<div align="center" style="padding-top: 5;">
						当前第 <font color="red">${page.currentPage}/${page.totalPage}</font>页&nbsp;
						共 <font color="red">${page.totalCount}</font>条记录 每页 <font color="red">${page.everyPage
							}</font>条

						<s:if test="#request.page.hasPrePage">
							<input type="button" name="btnTopPage" id="btnTopPage"
								value="|&lt;&lt; " title="首页" onClick="topPage()">
							<input type="button" name="btnPreviousPage" id="btnPreviousPage"
								value=" &lt;  " title="上页" onClick="previousPage()">

						</s:if>
						<s:else>
							<input type="button" name="btnTopPage" id="btnTopPage"
								value="|&lt;&lt; " title="首页" onClick="topPage()"
								disabled="disabled">
							<input type="button" name="btnPreviousPage" id="btnPreviousPage"
								value=" &lt;  " title="上页" onClick="previousPage()"
								disabled="disabled">
						</s:else>
						<s:if test="#request.page.hasNextPage">
							<input type="button" name="btnNextPage" id="btnNextPage"
								value="  &gt; " title="下页" onClick="nextPage()">
							<input type="button" name="btnBottomPage" id="btnBottomPage"
								value=" &gt;&gt;|" title="尾页" onClick="bottomPage()">
						</s:if>
						<s:else>
							<input type="button" name="btnNextPage" id="btnNextPage"
								value="  &gt; " title="下页" onClick="nextPage()"
								disabled="disabled">
							<input type="button" name="btnBottomPage" id="btnBottomPage"
								value=" &gt;&gt;|" title="尾页" onClick="bottomPage()"
								disabled="disabled">
						</s:else>
						<input type="button" name="btnAdd" id="btnAdd" value="添加"
							onClick="window.location.href='addPaperSourceType.jsp'">
						<input type="button" name="btnDel" id="btnDel" value="删除"
							onClick="deleteList()"> <input type="hidden"
							name="page.currentPage" id="currentPage"
							value="${page.currentPage}">
					</div>
				</form>
			</div>
		</div>

	</div>
	<div class="foot" align="center">
		<jsp:include page="foot.jsp"></jsp:include>
	</div>
</body>
</html>
